package com.zhhh.domain;
// Generated 2019-9-27 10:55:05 by Hibernate Tools 3.4.0.CR1

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * BUser generated by hbm2java
 */
@Entity
@Table(name = "b_user")
public class BUser implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String usercode;
	private String username;
	private String password;
	private Date sdate;
	private Date edate;
	private String phone;
	private String email;
	private Integer status;
	private Integer sortno;
	private String OSysCode;
	private String SSysCode;

	private List<BOrganization> organizations = new ArrayList<BOrganization>();

	private Set<BRole> roles = new HashSet<BRole>();

	public BUser() {
	}

	public BUser(String usercode, String username, String password, Date sdate, Date edate, String phone, String email,
			Integer status, Integer sortno, String OSysCode, String SSysCode) {
		this.usercode = usercode;
		this.username = username;
		this.password = password;
		this.sdate = sdate;
		this.edate = edate;
		this.phone = phone;
		this.email = email;
		this.status = status;
		this.sortno = sortno;
		this.OSysCode = OSysCode;
		this.SSysCode = SSysCode;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)

	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "usercode", length = 40)
	public String getUsercode() {
		return this.usercode;
	}

	public void setUsercode(String usercode) {
		this.usercode = usercode;
	}

	@Column(name = "username", length = 20)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "password", length = 50)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "sdate", length = 10)
	@DateTimeFormat(pattern = "yyyy-MM-dd") // 格式：年-月-日
	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") // 东八区
	public Date getSdate() {
		return this.sdate;
	}

	public void setSdate(Date sdate) {
		this.sdate = sdate;
	}

	// date 类型json转换异常 未知原因
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "edate", length = 10)
	@DateTimeFormat(pattern = "yyyy-MM-dd") // 格式：年-月-日
	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") // 东八区
	public Date getEdate() {
		return this.edate;
	}

	public void setEdate(Date edate) {
		this.edate = edate;
	}

	@Column(name = "phone", length = 20)
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Column(name = "email")
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "status")
	public Integer getStatus() {
		return this.status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Column(name = "sortno")
	public Integer getSortno() {
		return this.sortno;
	}

	public void setSortno(Integer sortno) {
		this.sortno = sortno;
	}

	@Column(name = "o_sys_code", length = 40)
	public String getOSysCode() {
		return this.OSysCode;
	}

	public void setOSysCode(String OSysCode) {
		this.OSysCode = OSysCode;
	}

	@Column(name = "s_sys_code", length = 40)
	public String getSSysCode() {
		return this.SSysCode;
	}

	public void setSSysCode(String SSysCode) {
		this.SSysCode = SSysCode;
	}

	// 关联组织机构
	@ManyToMany(cascade = CascadeType.REFRESH)
	@JoinTable(name = "b_user_organization", inverseJoinColumns = @JoinColumn(name = "organization_id"), joinColumns = @JoinColumn(name = "usert_id"))
	@JsonIgnore // 我中有你你中有我的情况jiuhu
	public List<BOrganization> getOrganizations() {
		return organizations;
	}

	public void setOrganizations(List<BOrganization> organizations) {
		this.organizations = organizations;
	}

	// 关联角色
	@ManyToMany(cascade = CascadeType.REFRESH)
	@JoinTable(name = "b_user_role", inverseJoinColumns = @JoinColumn(name = "role_id"), joinColumns = @JoinColumn(name = "usert_id"))
	@JsonIgnore // 我中有你你中有我的情况jiuhu
	public Set<BRole> getRoles() {
		return roles;
	}

	public void setRoles(Set<BRole> roles) {
		this.roles = roles;
	}

}
